$(function () {
    useLayUI();
})
var sendResume = new Vue({
    el: "#send_resume",
    data() {
        return {
            services: services,
            // userInfo:'',
            bid:'',
            positionData:[],
            companyData:[],
            username:"",
            
        }
    },
    created () {
    	// var date = new Date();
    	// expires_time = date.setTime(date.getTime()+30*60*1000);
     //    this.userInfo = LoginStatus();
        // if(this.userInfo==false){
        // 	 $.cookie("curren_url",window.location.href,{ expires: expires_time, path: '/' })
        //     return false;
        // }
        // this.username = this.userInfo.name;

        // console.log(this.userInfo);
        this.bid = GetQueryString('id');
        if(this.bid==null||this.bid==""){
            layerMsg("扫描错误！请重新扫描")
            setTimeout(function() {
                window.location.href="my-resume.html" ;
            },3000);
            return false;
        }
        this.init();

       console.log(this.positionData)

    },
    methods:{
        init:function () {
            var that=this;
            $.ajax({
                url:that.services+"/booth/position/list/"+this.bid+"?page=1&limit=200"
                ,type:"get"
                ,async:false
                ,xhrFields: {
                    withCredentials: true
                }
                ,crossDomain: true
                ,success:function(res){
                    var check = ApiLoginStatus(res)
                    if(check==false)
                        return false;
                    if(res.success){
                        that.positionData = res.data
                    }
                }
            });
            for(var i=0;i<that.positionData.length;i++){
                var positionName = that.positionData[i].positionName;
                var companyFullName = that.positionData[i].companyFullName;
            
                $.ajax({
                    url:that.services+"/user/resume/delivery/list?page=1&limit=200&status=&companyFullName="+companyFullName+"&positionName="+positionName
                    ,type:"get"
                    ,async:false
                    ,xhrFields: {
                        withCredentials: true
                    }
                    ,crossDomain: true
                    ,success:function(res){
                        var check = ApiLoginStatus(res)
                        if(check==false)
                            return false;
                        var obj = JSON.parse(res) 
                        if(obj.count>0){
                            that.positionData[i].check = true;
                        }else{
                            that.positionData[i].check = false;
                        }
                    }
                });
            }
            if(that.positionData==null){
                layerMsg("该摊位未发布职位，请另选摊位")
                setTimeout(function() {
                    window.location.href="my-resume.html" ;
                },3000);
                return false;
            }
            var id = that.positionData[0].companyId
            // console.log(id)
            $.ajax({
                url:that.services+"/user/company/"+id
                ,type:"get"
                ,async:false
                ,xhrFields: {
                    withCredentials: true
                }
                ,crossDomain: true
                ,success:function(res){
                    // console.log(res);
                    var check = ApiLoginStatus(res)
                    if(check==false)
                        return false;
                    if(res.success){
                        that.companyData = res.data
                        console.log( that.companyData)
                    }
                }
            });
        }
    }

    
});

